#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <ctime>
using std::string;
using std::vector;
using std::min;
using std::cin;
using std::cout;
using std::endl;

class BullsAndCows {
    struct Value {
        vector <int> count_of_number;
        vector <int> number;
        Value() {
            count_of_number.resize(10, 0);
            number.resize(4, 0);
        }
        void create_new() {
            for (int i = 0; i < 4; ++i) {
                number[i] = rand() % 10;
                ++count_of_number[number[i]];
            }
        }
    };

    Value hidden;

    Value string_to_value(string const &line) const {
        Value result;
        for (auto i = 0; i < 4; ++i) {
            result.number[i] = (int)(line[i] - '0');
            ++result.count_of_number[(int)(line[i] - '0')];
        }
        return result;
    }

    void print_hidden() {
        for (int i = 0; i < 4; ++i) {
            cout << hidden.number[i];
        }
        cout << endl;
    }
public:
    struct Answer {
        int cows;
        int bulls;
        bool win;
    };

    void start_game() {
        hidden.create_new();
#ifdef _DEBUG 
        print_hidden();
#endif
    }
    Answer count_answer(string const &guess) const {
        Answer answer;
        int cows = 0;
        int bulls = 0;
        Value question = string_to_value(guess);
        for (int i = 0; i < 10; ++i) {
            cows += min(question.count_of_number[i],
                hidden.count_of_number[i]);
        }
        for (int i = 0; i < 4; ++i) {
            if (hidden.number[i] == question.number[i]) {
                ++bulls;
            }
        }
        answer.bulls = bulls;
        answer.cows = cows;
        answer.win = (bulls == 4);
        return answer;
    }
};

void Game() {
    srand(time(NULL));
    BullsAndCows Game;
    Game.start_game();
    cout << "Game started!" << endl;
    string question;
    BullsAndCows::Answer answer;
    bool is_bad_input;
    do {
        do {
            cout << "Input number length 4: ";
            cin >> question;
            is_bad_input = 0;
            for (int i = 0; i < question.size(); ++i) {
                if (question[i] < '0' || question[i] > '9') {
                    is_bad_input = 1;
                    break;
                }
            }
            if (is_bad_input == 1 || question.size() != 4) {
                cout << "Bad input!" << endl;
            }
        } while (question.size() != 4 || is_bad_input);
        answer = Game.count_answer(question);
        cout << answer.cows << " " << answer.bulls << endl;
    } while (answer.win == 0);
    cout << "WIN" << endl;
}

int main() {
    Game();
}